package com.neo.sevice;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.neo.SpringBootShiroApplication;
import com.neo.entity.SysPermission;
import com.neo.entity.SysRole;
import com.neo.entity.UserInfo;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = SpringBootShiroApplication.class)
public class TestNeo {
	
	@Autowired
	private UserInfoService userInfoService;
	
	
	@Test
	public void testFindAllUserInfo() {
		userInfoService.findAllUserInfo();
		
	}
	
	@Test
	public void testCreatTable() {
		userInfoService.initLoginData();
		
	}

	@Test
	public void testUserInfoFindUserName() {
		UserInfo userInfo = userInfoService.findByUsername("admin");
//		System.out.println(userInfoService.findByUsername("admin"));
		System.out.println(userInfo.getPassword());
		System.out.println("------------------------------");
		for (SysRole sysRole : userInfo.getRoleSet()) {
			System.out.println("sysRole: "+sysRole.getDescription());
			for (SysPermission sysPermission : sysRole.getPermissions()) {
				System.out.println(sysPermission.getName());
			}
		}
		
		
		/*Set<SysRole> sysRoles = userInfo.getRoleSet();
		System.out.println(sysRoles.size());
		for (SysRole sysRole : sysRoles) {
			System.out.println("sysRole: "+sysRole.getDescription());
			Set<SysPermission> sysPermissions = sysRole.getPermissions();
			for (SysPermission sysPermission : sysPermissions) {
				System.out.println(sysPermission.getName());
			}
		}*/
	}
}
